package com.fenghongzhang.day012;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;


/**
 * 有两种方式,
 * 1,静态, 清单文件中注册.
 * 2.动态, 代码中注册.
 */
public class MyReceiver extends BroadcastReceiver {

    private static final String TAG = "MyReceiver";
    //在这个方法会被调用
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction(); //得出频道


        if(action.equals("com.feng")){
            //启动一个activity
            String name = intent.getStringExtra("name");
            Log.i(TAG, "onReceive: "+name);
        }else if(action.equals("com.feng1")){
            //启动另外一个acitivty
            String name = intent.getStringExtra("name");
            Log.i(TAG, "onReceive: "+name);
        }


    }
}
